<template>
  <div class="companyOperations-box">
    <!-- 库存、外协、客户，使用的封装表格 -->
    <div class="companyOperations-table">
      <el-table
        ref="TableRef"
        :data="tableData"
        style="width: 100%; overflow-y: scroll"
        :max-height="tableHeight"
        :height="props.height"
        border
        @selection-change="handleSelectionChange"
        @select="handleSelect"
        :row-class-name="tableRowClassName"
        :row-style="{ height: 0 + 'px' }"
        :cell-style="{ padding: 0 + 'px' }"
        :header-cell-style="{
          background: '#F5F7FA',
          color: `${color}`,
          height: '10px',
          padding: '0px',
        }"
        :show-summary="props.showSummary"
        :summary-method="getSummaries"
      >
        <!--        @cell-dblclick="tableDetail"-->
        <el-table-column v-if="props.selection" type="selection" width="30" fixed />
        <!-- 表格数据 -->
        <el-table-column
          v-for="(item,index) in tableHeaderData" :key="index"
          :sortable="item.sortable || false"
          :sort-orders="['ascending', 'descending', null]"
          :prop="item.prop"
          :fixed="item.fixed"
          :min-width="item.minwidth"
          :max-width="item.maxwidth"
          :width="item.width"
          :label="item.label"
          :class-name="item.colorClassName"
          show-overflow-tooltip
          :align="'center'"
        >
          <template #default="scope">
            <!-- 荣誉管理————荣誉级别展示 -->
              <div v-if="item.certificateLevelHonorShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span v-show="scope.row.certificateLevel===1">校级</span>
              <span v-show="scope.row.certificateLevel===2">市级</span>
              <span v-show="scope.row.certificateLevel===3">省级</span>
              <span v-show="scope.row.certificateLevel===4">国家级</span>
            </div>
            <!-- 德育评价列表————组织展示 -->
             <div v-if="item.enterpriseDeptShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span>{{ scope.row.deptNameList.join(' / ') }}</span>
            </div>
            <!-- 自主活动————状态展示 -->
             <div v-if="item.statusActivityShow2" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span v-show="scope.row.status===0">申请中</span>
              <span v-show="scope.row.status===1 || scope.row.status===7">未开始</span>
              <span v-show="scope.row.status===2">报名中</span>
              <span v-show="scope.row.status===3">进行中</span>
              <span v-show="scope.row.status===4">已结束</span>
              <span v-show="scope.row.status===6">已拒绝</span>
              <span v-show="scope.row.status===8 || scope.row.status===9">已暂停</span>
            </div>
            <!-- 活动详情页面-报名时间、积分、状态展示 -->
            <div v-if="item.applyTimeActivityShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span>{{ dayjs(scope.row.applyTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
            </div>
            <div v-if="item.scoreActivityShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span>{{ scope.row.score? scope.row.score : '0' }}</span>
            </div>
            <div v-if="item.statusDeatailActivityShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span v-show="scope.row.status===0">待审核</span>
              <span v-show="scope.row.status===1">已通过</span>
              <span v-show="scope.row.status===2">已拒绝</span>
              <span v-show="scope.row.status===3">已取消</span>
            </div>
            <!-- 活动列表页面-报名时间、活动时间、活动范围、得分标准、状态、已报名人数、活动封面展示 -->
            <div v-if="item.signupActivityShow" :class="scope.row[item.prop]">
              <span>{{ scope.row.signupStart.slice(0,16) }} - {{ scope.row.signupEnd.slice(0,16) }}</span>
            </div>
            <div v-if="item.activityTimeShow" :class="scope.row[item.prop]">
              <span>{{ scope.row.activityStart.slice(0,16) }} - {{ scope.row.activityEnd.slice(0,16) }}</span>
            </div>
            <div v-if="item.activityScopeNameListShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span>{{ scope.row.activityScopeNameList.join('/') }}</span>
            </div>
            <div v-if="item.activityPersonListShow" :class="scope.row[item.prop]">
              <span>{{ scope.row.activityParticipationList.length > 0 ? scope.row.activityParticipationList.length : '0' }}</span>
            </div>
            <div v-if="item.scoreTypeActivityShow" :class="scope.row[item.prop]">
              <span v-show="scope.row.scoreType===1">参与得分</span>
              <span v-show="scope.row.scoreType===2">指标评分</span>
              <span v-show="scope.row.scoreType===3">区间得分</span>
            </div>
            <div v-if="item.statusActivityShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span v-show="scope.row.status===1 || scope.row.status===7">未开始</span>
              <span v-show="scope.row.status===2">报名中</span>
              <span v-show="scope.row.status===3">进行中</span>
              <span v-show="scope.row.status===4">已结束</span>
              <span v-show="scope.row.status===8 || scope.row.status===9">已暂停</span>
            </div>
            <div v-if="item.coverImageUrlShow" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <img v-if="scope.row.coverImageUrl" class="tabelimg" :src="scope.row.coverImageUrl" alt="">
              <span v-else>暂无照片</span>
            </div>
            <!-- 活动分类列表页面-状态展示 -->
            <div v-if="item.activityClassifyStatus" :class="scope.row[item.prop]">
              <el-switch
              @change="changeStatus(scope.row.id, scope.row.status)"
              v-model="scope.row.status"
              class="ml-2"
              style="
                --el-switch-on-color: #13ce66;
                --el-switch-off-color: #ff4949;
              "
            />
            </div>
            <!-- 个人积分列表页面-编号展示 -->
            <div v-if="item.activityIdGrade" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span>{{ scope.row[item.prop]==null? '--' : scope.row[item.prop] }}</span>
            </div>
            <!-- 学生成绩列表页面-男女展示 -->
            <div v-if="item.sexGrade" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span v-show="scope.row[item.prop]==='0' ">男</span>
              <span v-show="scope.row[item.prop]==='1' ">女</span>
            </div>
            <!-- 资料列表类型展示 -->
            <div v-if="item.prop == 'categoryCode'" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              <span v-show="scope.row[item.prop]==='30001'">视频</span>
              <span v-show="scope.row[item.prop]==='30002'">PDF</span>
              <span v-show="scope.row[item.prop]==='30003'">文档</span>
            </div>
            <!-- 文件大小展示 -->
            <div v-if="item.sizeChange" :class="scope.row[item.prop]"
            style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
              {{ formatFileSize(scope.row[item.prop]) }}
            </div>
            <!-- 日期去掉秒 -->
            <div
              v-if="item.prop == 'orderDate'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
            >
              {{ scope.row[item.prop].slice(0, 10) }}
            </div>
            <!-- 预警样式 -->
            <div
              v-if="item.prop == 'stockroomNumber'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop] < threshold ? 'stockroomNumber' : 'stockroomNumber'"
            >
              {{ scope.row[item.prop] < threshold ? '库存不足' : '库存不足' }}
            </div>
            <!-- 成本核算 ，测量单-->
            <div
              v-if="item.prop == 'designType'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!-- 成本核算 ，核算单-->
            <div
              v-if="item.prop == 'type'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!-- 审核状态 ，设计中心审核状态-->
            <div
              v-if="item.prop == 'auditStatus'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <div
              v-if="item.prop == 'customerType'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ CUSTOMERTYPE[scope.row[item.prop]] }}
            </div>
            <div
              v-if="item.prop == 'outsourcingType'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ OUTSOURCINGTYPE[scope.row[item.prop]] }}
            </div>
            <div
              v-if="item.prop == 'customerSource'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ CUSTOMERSOURCE[scope.row[item.prop]] }}
            </div>
            <!-- <div
              v-if="item.prop == 'status' "
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div> -->
            <!-- 通知公告 -->
            <div
              v-if="item.prop == 'noticeType'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!-- 企业评价状态 -->
             <div
              v-if="item.prop == 'status' && item.pageType=='qiyeStatus'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              <p v-show="scope.row[item.prop]===0">未审核</p>
              <p v-show="scope.row[item.prop]===1">已通过</p>
              <p v-show="scope.row[item.prop]===2">已拒绝</p>
            </div>
            <!-- 工单管理 ，销售单明细-->
            <div
              v-if="item.prop == 'invoiceStatus'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!-- 订单利润管理/合同管理 ，是否下单前回款-->
            <div
              v-if="item.prop == 'isPayment'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] == 0 ? '否' : '是' }}
            </div>
            <!-- <div v-if="item.prop == 'invoiceStatus'" :class="scope.row[item.prop] ? '已开票' : '未开票'">
                {{ scope.row[item.prop] ? '已开票' : '未开票' }}
            </div> -->
            <!-- 外协管理 外协商工费管理 -->
            <div
              v-if="item.prop == 'paymentStatus'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!-- 客户等级 -->
            <div
              v-if="item.prop == 'customerRank'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!-- 客户管理 客户联系记录 -->
            <div
              v-if="item.prop == 'underwayOutcome'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!-- 到期提醒 -->
            <div
              v-if="item.prop == 'remindWarn'"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
              :class="scope.row[item.prop]"
            >
              {{ scope.row[item.prop] }}
            </div>
            <!--            售后处理-->
            <div
              v-if="
                item.prop == 'operate' &&
                scope.row['type'] === '待处理' &&
                props.typeView === '售后'
              "
              :class="scope.row[item.prop]"
              style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
            >
              <el-button type="primary" @click="operateAfterSales(scope.row)">处理</el-button>
            </div>
            <!-- 安装队图片展示 -->
            <div
              v-if="
                (item.prop &&
                  item.prop.includes('Photos') &&
                  item.prop !== 'acceptancePhotos' &&
                  item.prop !== 'acceptanceFormPhotos') ||
                item.prop === 'payBills'
              "
              class="photos"
            >
              <div
                style="
                  border: 1px dashed #ccc;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  padding: 4px;
                "
              >
                <div
                  v-if="!scope.row[item.prop]"
                  style="width: 80px; height: 40px"
                  class="el-image"
                >
                  <p class="el-image__error">暂未上传</p>
                </div>
                <el-image
                  v-else
                  style="width: 80px; height: 40px"
                  :src="JSON.parse(scope.row[item.prop])[0]"
                  lazy
                  preview-teleported="true"
                  :zoom-rate="1.2"
                  :max-scale="7"
                  :min-scale="0.2"
                  :preview-src-list="JSON.parse(scope.row[item.prop])"
                />
              </div>
            </div>
            <!-- 设计中心设计稿-->
            <div
              v-if="item.prop == 'designDraft' || item.prop == 'designDrawings'"
              class="designDraft"
            >
              <div
                style="
                  border: 1px dashed #ccc;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  padding: 4px;
                "
              >
                <div
                  v-if="!scope.row[item.prop]"
                  style="width: 80px; height: 40px"
                  class="el-image"
                  @click="updatePhotos(scope.row)"
                >
                  <p class="el-image__error">上传图片</p>
                </div>
                <el-image
                  v-else
                  style="width: 80px; height: 40px"
                  :src="scope.row[item.prop][0]"
                  lazy
                  preview-teleported="true"
                  :zoom-rate="1.2"
                  :max-scale="7"
                  :min-scale="0.2"
                  :preview-src-list="scope.row[item.prop]"
                />
              </div>
            </div>

            <!-- 上传照片模型-->
            <div v-if="item.prop === 'photosModel'" class="designDraft">
              <div class="upload" v-if="checkPermi(['system:teams:orderEdit'])">
                <ImageUpload
                  :limit="6"
                  :isShowTip="false"
                  @update:modelValue="handlerModelValue(scope.row, $event)"
                  :fileType="fileType"
                  :modelValue="JSON.parse(scope.row[item.prop])"
                />
                <el-dialog v-model="dialogVisible">
                  <img w-full :src="dialogImageUrl" alt="Preview Image" />
                </el-dialog>
              </div>
              <div class="uploadMask" v-else>暂无权限上传图片</div>
            </div>
            <!-- 验收自拍照-->
            <div v-if="item.prop === 'acceptancePhotos'" class="designDraft">
              <div class="upload" v-if="checkPermi(['system:teams:orderEdit'])">
                <ImageUpload
                  :limit="6"
                  :isShowTip="false"
                  @update:modelValue="handlerModelAcceptance(scope.row, 1, $event)"
                  :fileType="fileType"
                  :modelValue="JSON.parse(scope.row[item.prop])"
                />
                <el-dialog v-model="acceptanceFlag">
                  <img w-full :src="acceptancePhotos" alt="Preview Image" />
                </el-dialog>
              </div>
              <div class="uploadMask" v-else>暂无权限上传图片</div>
            </div>
            <!--            验收单-->
            <div v-if="item.prop === 'acceptanceFormPhotos'" class="designDraft">
              <div class="upload" v-if="checkPermi(['system:teams:orderEdit'])">
                <ImageUpload
                  :limit="6"
                  :isShowTip="false"
                  @update:modelValue="handlerModelAcceptance(scope.row, 2, $event)"
                  :fileType="fileType"
                  :modelValue="JSON.parse(scope.row[item.prop])"
                />
                <el-dialog v-model="acceptanceFormFlag">
                  <img w-full :src="acceptanceFormPhotos" alt="Preview Image" />
                </el-dialog>
              </div>
              <div class="uploadMask" v-else>暂无权限上传图片</div>
            </div>
            <!-- 验收回访 -->
            <div class="isCheck" v-if="item.prop == 'replyCustomers'">
              <el-checkbox
                v-model="scope.row[item.prop]"
                size="large"
                @change="changeIsReturn(scope.row.installationProcessId, $event)"
              />
            </div>
            <!-- 验收备注 -->
            <div
              class="isinput"
              style="width: 100%; min-height: 50px"
              v-if="item.prop === 'acceptanceRemark'"
              @dblclick="
                () => {
                  scope.row.isinput = true
                  inputRemarkRef[scope.$index].focus()
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputRemarkRef"
                placeholder="备注"
                v-show="scope.row.isinput"
                @blur="scope.row.isinput = false"
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-show="!scope.row.isinput">{{ scope.row[item.prop] }}</p>
            </div>
            <!-- 保障管理 -->
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'reimbursementAmount'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputBaoRemarkRef"
                placeholder="输入"
                v-if="scope.row.isinput"
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'reimbursementDifference' && scope.row.reimbursementAmount"
            >
              {{
                scope.row.reimbursementAmount
                  ? scope.row.totalOrderAmount - scope.row.reimbursementAmount
                  : null
              }}
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'reimbursementDesc'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputBaoRemarkRef"
                placeholder="输入"
                v-if="scope.row.isinput"
                createRemark
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'billingStatus'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-select v-model="scope.row[item.prop]" clearable v-if="scope.row.isinput">
                <el-option
                  v-for="(item1, index) in kaipiaoOptions"
                  :key="item1.id"
                  :label="item1.label"
                  :value="item1.id"
                  filterable
                />
              </el-select>
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'billingAmount'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputBaoRemarkRef"
                placeholder="输入"
                v-if="scope.row.isinput"
                createRemark
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'billingDesc'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputBaoRemarkRef"
                placeholder="输入"
                v-if="scope.row.isinput"
                createRemark
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'billingDifference' && scope.row.billingAmount"
            >
              {{
                scope.row.billingAmount
                  ? scope.row.reimbursementAmount - scope.row.billingAmount
                  : null
              }}
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'paymentDesc'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputBaoRemarkRef"
                placeholder="输入"
                v-if="scope.row.isinput"
                createRemark
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>
            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'paymentAmount'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputBaoRemarkRef"
                placeholder="输入"
                v-if="scope.row.isinput"
                createRemark
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>

            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'paymentDifference' && scope.row.paymentAmount"
            >
              {{
                scope.row.paymentAmount
                  ? (scope.row.billingAmount - scope.row.paymentAmount).toFixed(2)
                  : null
              }}
            </div>

            <div
              class="isinput"
              style="width: 100%; min-height: 40px"
              v-if="item.prop == 'remarkBilling'"
              @click="
                () => {
                  scope.row.isinput = true
                }
              "
            >
              <el-input
                v-model="scope.row[item.prop]"
                style="width: 100%; height: 100%"
                autosize
                type="textarea"
                ref="inputBaoRemarkRef"
                placeholder="输入"
                v-if="scope.row.isinput"
                createRemark
                @keyup.enter="scope.row.isinput = false"
              />
              <p v-if="!scope.row.isinput" style="width: max-content; height: max-content">
                {{ scope.row[item.prop] }}
              </p>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          class-name="operate"
          :align="'center'"
          v-if="props.operate"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="viewFiles(scope.$index, scope.row)" v-show="scope.row.files"
              >查看附件</span
            >
            <span @click="downloadFiles(scope.$index, scope.row)" v-show="scope.row.files"
              >下载附件</span
            >
            <span v-show="!scope.row.files" style="color: #ff7d00">请上传合同</span>
          </template>
        </el-table-column>

        <el-table-column
          label="操作"
          class-name="operate"
          :align="'center'"
          v-if="props.profitUpdate"
          width="160"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="goDetail(scope.row)">详情</span>
            <span @click="profitUpdate(scope.row)">计算成本</span>
          </template>
        </el-table-column>
        <slot></slot>
        
        <!-- 消息通知列表页面-列表操作栏-查看按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.messageOperation"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span  @click="messageView(scope.$index, scope.row)">查看</span>
          </template>
        </el-table-column>
        <!-- 活动列表页面-列表操作栏-查看+编辑+删除按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.activityListsShow"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span  @click="activityListsView(scope.$index, scope.row)">查看</span>
            <span  @click="activityListsEdit(scope.$index, scope.row)">编辑</span>
          </template>
        </el-table-column>
        <!-- 荣誉管理列表页面-列表操作栏-查看+下载+拒绝+通过按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.honorShow"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span v-show="scope.row.status===0" @click="honorPass(scope.$index, scope.row)">通过</span>
            <span v-show="scope.row.status===0" style="color:red;"  @click="honorReject(scope.$index, scope.row)">拒绝</span>
            <span v-show="scope.row.status !==0" @click="honorView(scope.$index, scope.row)">查看</span>
            <span v-show="scope.row.status !==0" @click="honorDownload(scope.$index, scope.row)">下载</span>
          </template>
        </el-table-column>
        <!-- 自主活动列表页面-列表操作栏-查看+编辑+通过+拒绝按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.initiativeShow"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span v-show="scope.row.status===0" @click="initiativePass(scope.$index, scope.row)">通过</span>
            <span v-show="scope.row.status===0" style="color:red;"  @click="initiativeReject(scope.$index, scope.row)">拒绝</span>
            <span v-show="scope.row.status !==0" @click="initiativeView(scope.$index, scope.row)">查看</span>
            <span v-show="scope.row.status !==0 &&scope.row.status !==8&&scope.row.status !==9" @click="initiativeEdit(scope.$index, scope.row)">编辑</span>
          </template>
        </el-table-column>
        <!-- 活动列表详情页面-列表操作栏-赋分+移除+通过+拒绝按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.activityDetailShow"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span v-show="activityStatus===2 && scope.row.status !==1 &&scope.row.status !==2" @click="activityPass(scope.$index, scope.row)">通过</span>
            <span v-show="activityStatus===2 && scope.row.status !==1 &&scope.row.status !==2" style="color:red;" @click="activityReject(scope.$index, scope.row)">拒绝</span>
            <span v-show="activityStatus===3 || activityStatus===4" @click="scoring(scope.$index, scope.row)">赋分</span>
            <span v-show="activityStatus===3||activityStatus===2" style="color:red;" @click="activityDel(scope.$index, scope.row)">移除</span>
          </template>
        </el-table-column>
        <!-- 积分管理列表页面-列表操作栏-查看+编辑按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.pointShow"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="uploadView(scope.$index, scope.row)">查看</span>
            <span @click="uploadEdit(scope.$index, scope.row)">编辑</span>
          </template>
        </el-table-column>
        <!-- 学生成绩列表页面-列表操作栏-查看+生成证书按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.gradeSetShow"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="uploadView(scope.$index, scope.row)">查看</span>
            <span @click="uploadEdit(scope.$index, scope.row)">生成证书</span>
          </template>
        </el-table-column>
         <!-- 资料列表页面-列表操作栏-下载按钮 -->
        <el-table-column
          label="资料下载"
          class-name="devise"
          :align="'center'"
          v-if="props.uploadDownloadShow"
          width="150"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="uploadYulan(scope.$index, scope.row)">预览</span>
            <span @click="uploadDownload(scope.$index, scope.row)">下载</span>
          </template>
        </el-table-column>
        <!-- 资料列表页面-列表操作栏-查看+删除+编辑按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.uploadShow"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="uploadYulan(scope.$index, scope.row)">查看</span>
            <span @click="uploadDownload(scope.$index, scope.row)">下载</span>
            <span v-if="checkPermi(['system:resource:edit'])" style="color:red;" @click="uploadDel(scope.$index, scope.row)">删除</span>
          </template>
        </el-table-column>
        <!-- 分类管理页面-列表操作栏-删除按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.activityOperation"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="activityDetele(scope.$index, scope.row)">编辑</span>
          </template>
        </el-table-column>
        <!-- 活动信息页面-列表操作栏-下载按钮 -->
        <el-table-column
          label="证明材料"
          class-name="devise"
          :align="'center'"
          v-if="props.download"
          width="100"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="downloadPass(scope.$index, scope.row)">下载</span>
          </template>
        </el-table-column>
        <!-- 活动信息页面-列表操作栏-通过+删除按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.auditOperation"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="auditPass(scope.$index, scope.row)">通过</span>
            <span style="color:red;" @click="auditDetele(scope.$index, scope.row)">删除</span>
          </template>
        </el-table-column>
        <!-- 企业评价页面-列表操作栏-通过+拒绝+评价按钮 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.appraiseOperation"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="appraisePingJia(scope.$index, scope.row)">查看</span>
            <span v-if="scope.row.status===0" @click="appraisePass(scope.$index, scope.row)">通过</span>
            <span v-if="scope.row.status===0" style="color:red;" @click="appraiseRefuse(scope.$index, scope.row)">拒绝</span>
          </template>
        </el-table-column>

        <!-- 设计中心 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.devise"
          width="180"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="through(scope.$index, scope.row)">通过</span>
            <span @click="overrule(scope.$index, scope.row)">驳回</span>
          </template>
        </el-table-column>
        <!-- 客户报账明细 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.billing"
          width="120"
          :fixed="'right'"
        >
          <template #default="scope">
            <div v-if="checkPermi(['system:orderCaiWu:edit'])">
              <span @click="billingBtn(scope.$index, scope.row)" v-if="scope.row.isinput"
                >保存</span
              >
            </div>
          </template>
        </el-table-column>
        <!-- 客户拜访详情 / 采购详情 -->
        <el-table-column
          label="操作"
          class-name="devise"
          :align="'center'"
          v-if="props.visitDetail || props.isHasDetail"
          width="120"
          :fixed="'right'"
        >
          <template #default="scope">
            <span @click="handleDetail(scope.$index, scope.row)">详情</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pageNum">
      <p></p>
      <Pagination
        :total="props.total"
        :pageSizes="props.pageSize"
        @pagination="handleChange"
        @update:page="updatePage"
        @update:limit="updateLimit"
        :page="props.page"
        :limit="props.limit"
        v-if="props.pagination"
      />
    </div>
    <PopUps v-if="profitUpdateView" widthMy="60%" height-my="78%">
      <i class="iconfont icon-close" @click="profitUpdateView = false"></i>
      <div class="setcompanyOperations">
        <label>
          提成%:
          <el-input style="width: 240px" v-model="ticheng"></el-input>
        </label>
        <label>
          税点%:
          <el-input style="width: 240px" v-model="shuidian"></el-input>
        </label>
        <div class="btn-sub">
          <el-button type="primary" @click="handleCalculateCost">保存</el-button>
        </div>
      </div>
    </PopUps>
  </div>
</template>
<script setup>
import { ref, onMounted, onUnmounted, defineEmits, defineProps, computed } from 'vue'
import PopUps from '@/components/My/PopUps/index.vue'
// import { getupdateOrderApi } from '@/api/tickets/index'
// import { CUSTOMERTYPE, CUSTOMERSOURCE, OUTSOURCINGTYPE } from '@/utils/enum.js'
const { proxy } = getCurrentInstance()
import Pagination from '@/components/Pagination/index'
import { checkPermi } from '@/utils/permission.js'
import ImageUpload from '@/components/ImageUpload/index.vue'
import dayjs from 'dayjs';
// import {activityStatusApi} from '@/api/activityClassify/activityClassifyType.js'
// import {
//   updateAcceptanceApi,
//   updateReplyCustomersApi,
//   uploadConstructionApi,
// } from '@/api/teams/index.js'
// 图片类型
let fileType = ['png', 'jpg', 'jpeg', 'jfif']
// 存放的设计及图
let designDrawings = reactive([])
const dialogVisible = ref(false)
const dialogImageUrl = ref('')

const acceptancePhotos = ref(null)
const acceptanceFlag = ref(false)
const acceptanceFormPhotos = ref(null)
const acceptanceFormFlag = ref(false)
// 回显的数据
let modelValue = ref([])

// 报账明显 开票状态
const kaipiaoOptions = ref([
  {
    id: '未开票',
    label: '未开票',
  },
  {
    id: '已开票',
    label: '已开票',
  },
])
// 获取的图片
const handlerModelValue = async (row, v) => {
  designDrawings = v
  let params = {
    id: row.id,
    photosModel: JSON.stringify(designDrawings),
    status: '待分配',
  }
  let { code } = await uploadConstructionApi(params)
  if (code === 200) {
    proxy.$modal.msgSuccess('文件上传成功')
  } else {
    designDrawings = []
    proxy.$modal.msgError('文件上传失败')
  }
  emit('getList')
}

const handlerModelAcceptance = async (row, i, v) => {
  if (i === 1) {
    let params = {
      installationProcessId: row.installationProcessId,
      orderId: row.orderId,
      acceptancePhotos: JSON.stringify(v),
    }
    let { code, msg } = await updateAcceptanceApi(params)
    if (code === 200) {
      proxy.$modal.msgSuccess(msg)
    } else {
      proxy.$modal.msgError('文件上传失败')
    }
    emit('getList')
  } else if (i === 2) {
    let params = {
      installationProcessId: row.installationProcessId,
      orderId: row.orderId,
      acceptanceFormPhotos: JSON.stringify(v),
    }
    let { code, msg } = await updateAcceptanceApi(params)
    if (code === 200) {
      proxy.$modal.msgSuccess(msg)
    } else {
      proxy.$modal.msgError('文件上传失败')
    }
    emit('getList')
  }
}
const operateAfterSales = (row) => {
  emit('operateAfterSales', row)
}
let emit = defineEmits([
  'optionTime',
  'handleChange',
  'updatePage',
  'genxinList',
  'updatePhotos',
  'billingBtn',
  'handleDetail',
  'updateLimitHandler',
  'handleSelectionChange',
  'viewFiles',
  'activityDetele',
  'auditDetele',
  'auditPass',
  'downloadPass',
  'downloadFiles',
  'tableDetail',
  'scrollhandler',
  'through',
  'overrule',
  'operateAfterSales',
  'goProfitDetail',

  'appraisePingJia', //德育评价-评价
  'appraisePass',          // -通过
  'appraiseRefuse',         // -拒绝
  'uploadView',      //资料上传-查看
  'uploadDel',              //删除
  'uploadDownload',         //下载
  'uploadEdit',             //编辑
  'uploadYulan',            //预览
  'changeStatus',    //活动分类-状态
  'scoring',         //活动列表详情-赋分
  'activityDel',     //      //移除
  'activityPass',            //通过
  'activityReject',          //拒绝
  'initiativeView',  //自主活动-查看
  'initiativeEdit',          //编辑
  'initiativePass',          //通过
  'initiativeReject',        //拒绝
  'honorView',       //荣誉管理-查看
  'honorDownload',           //下载
  'honorPass',               //通过
  'honorReject',             //拒绝
  'activityListsView', //活动列表-查看
  'activityListsEdit',       //编辑
  'messageView',       //消息通知-查看
]) 
const TableRef = ref(null)
// 预警数量阈值
const threshold = ref(10000)
// 表格高度
let tableHeight = ref(window.innerHeight - 300)
// 选中色的id
let selectID = ref([])
// 权限

const ticheng = ref()
const shuidian = ref()

let profitUpdateView = ref(false)

let inputRemarkRef = ref('')
let inputBaoRemarkRef = ref('')
// 传递的参数
const props = defineProps({
  // 显示勾选栏
  selection: {
    type: Boolean,
    default: true,
  },
  // 字体颜色
  color: {
    type: String,
    default: '#333',
  },
  // 表格表头背景颜色
  bg: {
    type: String,
    default: '#fff',
  },
  // 显示操作栏
  activityListsShow: {
    type: Number,
    default: null,
  },
  // 显示操作栏
  messageOperation: {
    type: Number,
    default: null,
  },
  // 显示操作栏
  activityStatus: {
    type: Number,
    default: null,
  },
   // 显示操作栏
  honorShow: {
    type: Boolean,
    default: false,
  },
  // 显示操作栏
  operate: {
    type: Boolean,
    default: false,
  },
  //显示操作栏
  activityOperation:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  uploadShow:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  activityDetailShow:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  gradeSetShow:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  pointShow:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  initiativeShow:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  auditOperation:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  appraiseOperation:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  download:{
    type: Boolean,
    default: false,
  },
  //显示操作栏
  uploadDownloadShow:{
    type: Boolean,
    default: false,
  },
  // 显示操作栏
  stockroomNumber: {
    type: Boolean,
    default: true,
  },
  //  显示设计中心操作栏
  devise: {
    type: Boolean,
    default: false,
  },
  // 显示分页器
  pagination: {
    type: Boolean,
    default: true,
  },
  // 页数大小
  pageSize: {
    type: Array,
    default() {
      return [10, 20, 30, 50]
    },
  },
  // 总共页数
  total: {
    type: Number,
    default: 200,
  },
  // 页数
  page: {
    type: Number,
    default: 1,
  },
  // 页数条数
  limit: {
    type: Number,
    default: 10,
  },
  // 时间
  Timeline: {
    type: Array,
    default: [
      {
        time: '年度',
        index: 0,
      },
      {
        time: '季度',
        index: 1,
      },
      {
        time: '月度',
        index: 2,
      },
    ],
  },
  // 表格表头
  tableHeaderData: {
    type: Array,
    default: [],
  },
  // 表格内容
  tableData: {
    type: Array,
    default: [],
  },
  // 合计的不带分页的数据
  allData: {
    type: Array,
    default: [],
  },
  // 激活色
  idActive: {
    type: String,
    default: 'orderId',
  },
  height: {
    type: String,
    default: null,
  },
  profitUpdate: {
    type: Boolean,
    default: false,
  },
  billing: {
    type: Boolean,
    default: false,
  },
  typeView: {
    type: String,
    default: 'false',
  },
  // 客户拜访详情操作
  visitDetail: {
    type: Boolean,
    default: false,
  },
  // 详情操作
  isHasDetail: {
    type: Boolean,
    default: false,
  },
  // 客户报账明细 是否显示总计
  showSummary: {
    type: Boolean,
    default: false,
  },
})

// 计算所有数据的合计，没有数据的列不显示0
const getSummaries = (param) => {
  const { columns } = param
  const sums = []

  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = '合计'
      return
    }

    const prop = column.property

    // 检查该列是否有数值数据
    const hasData = props.allData.some((item) => {
      const val = item[prop]
      return val !== undefined && val !== null && val !== '' && !isNaN(Number(val))
    })

    if (!hasData) {
      sums[index] = '' // 没有数据的列显示为""
      return
    }

    // 计算有数据的列的合计
    const sum = props.allData.reduce((total, item) => {
      const value = Number(item[prop])
      if (!isNaN(value)) {
        return total + value
      }
      return total
    }, 0)

    // 仅对超过两位小数的数值保留两位小数
    if (Number.isInteger(sum)) {
      // 整数保持不变
      sums[index] = sum
    } else {
      const decimalPart = String(sum).split('.')[1]
      if (decimalPart && decimalPart.length > 2) {
        // 超过两位小数，保留两位
        sums[index] = parseFloat(sum.toFixed(2))
      } else {
        // 不超过两位小数，保持原样
        sums[index] = sum
      }
    }
  })

  return sums
}
const changeIsReturn = async (id, flag) => {
  let params = {
    installationProcessId: id,
    replyCustomers: flag ? 1 : 0,
  }
  await updateReplyCustomersApi(params)
}
// 编辑
const viewFiles = (i, v) => {
  emit('viewFiles', { i, v })
}
// 删除
const downloadFiles = (i, v) => {
  emit('downloadFiles', { i, v })
}
//消息通知————查看
const messageView = (i,v)=>{
   emit('messageView', { i, v })
}
//活动列表————查看/编辑
const activityListsView = (i,v)=>{
   emit('activityListsView', { i, v })
}
const activityListsEdit = (i,v)=>{
   emit('activityListsEdit', { i, v })
}
//荣誉管理————查看/下载/通过/拒绝
const honorReject = (i,v)=>{
   emit('honorReject', { i, v })
}
const honorView = (i,v)=>{
   emit('honorView', { i, v })
}
const honorDownload = (i,v)=>{
   emit('honorDownload', { i, v })
}
const honorPass = (i,v)=>{
   emit('honorPass', { i, v })
}
//自主活动————拒绝/通过/查看/编辑
const initiativeView = (i,v)=>{
   emit('initiativeView', { i, v })
}
const initiativeEdit = (i,v)=>{
   emit('initiativeEdit', { i, v })
}
const initiativePass = (i,v)=>{
   emit('initiativePass', { i, v })
}
const initiativeReject = (i,v)=>{
   emit('initiativeReject', { i, v })
}
//活动列表————拒绝/通过/移除/赋分
const activityReject = (i,v)=>{
   emit('activityReject', { i, v })
}
const activityPass = (i,v)=>{
   emit('activityPass', { i, v })
}
const activityDel = (i,v)=>{
   emit('activityDel', { i, v })
}
const scoring = (i,v)=>{
   emit('scoring', { i, v })
}
//分类管理页面删除
const activityDetele = (i,v)=>{
   emit('activityDetele', { i, v })
}
//活动信息页面删除/通过/下载
const auditDetele = (i,v)=>{
   emit('auditDetele', { i, v })
}
const auditPass = (i,v)=>{
   emit('auditPass', { i, v })
}
const downloadPass = (i,v)=>{
   emit('downloadPass', { i, v })
}

//资料列表页面查看/删除/编辑/下载/预览
const uploadView = (i,v)=>{
   emit('uploadView', { i, v })
}
const uploadDel = (i,v)=>{
   emit('uploadDel', { i, v })
}
const uploadEdit = (i,v)=>{
   emit('uploadEdit', { i, v })
}
const uploadDownload = (i,v)=>{
   emit('uploadDownload', { i, v })
}
const uploadYulan = (i,v)=>{
   emit('uploadYulan', { i, v })
}

//德育评价页面评价
const appraisePingJia = (i,v)=>{
   emit('appraisePingJia', { i, v })
}
//德育评价页面拒绝
const appraiseRefuse = (i,v)=>{
   emit('appraiseRefuse', { i, v })
}
//德育评价页面通过
const appraisePass = (i,v)=>{
   emit('appraisePass', { i, v })
}
//活动分类列表页面状态更改
const changeStatus = (id,status)=>{
   emit('changeStatus',{id,status})
}
// 通过
const through = (i, v) => {
  emit('through', { i, v })
}
// 通过
const overrule = (i, v) => {
  emit('overrule', { i, v })
}

/*客户拜访记录 详情操作*/
const handleDetail = (i, v) => {
  emit('handleDetail', { i, v })
  v.isinput = false
}

// 保存
const billingBtn = (i, v) => {
  emit('billingBtn', { i, v })
  v.isinput = false
}

const currentRow = ref()
// 修改利润
const profitUpdate = (row) => {
  profitUpdateView.value = true
  currentRow.value = row
  ticheng.value = []
  shuidian.value = []
}
// 查看利润
const goDetail = (row) => {
  emit('goProfitDetail', row)
}
// 监听浏览器屏幕变化展示对应的高度
onMounted(() => {
  window.onresize = () => {
    return (() => {
      tableHeight.value = window.innerHeight - 240
    })()
  }
})

// 拿到选中的行id
const handleSelect = (row) => {
  selectID.value = []
  if (row.length > 0) {
    row.forEach((value) => {
      selectID.value.push(value[props.idActive])
    })
  }
}
// 选中背景色
const tableRowClassName = ({ row }) => {
  let color = ''
  for (let item of selectID.value.values()) {
    if (item === row[props.idActive]) color = 'table-SelectedRow-bgcolor'
  }
  return color
}

// 分页器大小  当前分页器
const handleChange = (page, pageSize) => {
  emit('handleChange', { page, pageSize })
}
// 当前页面位置发生变化
const updatePage = (val) => {
  emit('updatePage', val)
}
// 条目个数发生变化
const updateLimit = (val) => {
  emit('updateLimitHandler', val)
}

// 选择的列
const handleSelectionChange = (val) => {
  emit('handleSelectionChange', val)
}
// 双击事件
const tableDetail = (row, column) => {
  if (!column.label) return
  emit('tableDetail', row)
}
// 上传图片
const updatePhotos = (v) => {
  emit('updatePhotos', v)
}

onMounted(() => {
  // 挂载
  TableRef.value && TableRef.value.$refs.bodyWrapper.addEventListener('mousewheel', scrollBehavior)
})

onUnmounted(() => {
  // 卸载
  TableRef.value &&
    TableRef.value.$refs.bodyWrapper.removeEventListener('mousewheel', scrollBehavior)
})

// 滚动行为
const scrollBehavior = (e) => {
  // 滚动方向判定
  const scrollDirection = e.deltaY > 0 ? 'down' : 'up'
  if (scrollDirection === 'down') {
    // 获取提供实际滚动的容器
    const dom = TableRef.value.$refs.bodyWrapper.getElementsByClassName('el-scrollbar__wrap')[0]
    const { clientHeight, scrollTop, scrollHeight } = dom
    if (scrollHeight - (clientHeight + scrollTop) === 0) {
      emit('scrollhandler')
    }
  }
}

// 修改接口
const getupdateOrderApiUpdate = async (params) => {
  let res = await getupdateOrderApi(params)
  let { code, msg } = res
  if (code === 200) {
    profitUpdateView.value = false
    ElMessage.success(msg)
    emit('genxinList')
  } else {
    ElMessage.error(msg)
  }
}
const handleCalculateCost = () => {
  currentRow.value.commission = (ticheng.value * currentRow.value.totalOrderAmount) / 100
  currentRow.value.tax = (shuidian.value * currentRow.value.totalOrderAmount) / 100
  const params = {
    ...currentRow.value,
  }
  getupdateOrderApiUpdate(params)
}
const formatFileSize = (bytes) => {  //显示文件大小
  if (bytes === 0) return '0 Bytes';
  const k = 1024;
  const sizes = ['Bytes', 'KB', 'MB', 'GB'];
  const i = Math.floor(Math.log(bytes) / Math.log(k));
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
};


const disabledStyle = {
  opacity: 0.5,
  cursor: 'not-allowed',
  'pointer-events': 'none'
};
const activeStyle = {
  cursor: 'pointer',
  opacity: 1
};
</script>

<style scoped lang="scss">
@mixin btn {
  font-size: 12px;
  border-radius: 2px;
  line-height: 25px;
  padding: 2px 5px;
}

.companyOperations-box {
  padding-top: 20px;
  box-sizing: border-box;
  height: 100%;

  // 发票状态
  :deep(.已开票) {
    color: #00b42a;
  }

  :deep(.未开票) {
    color: #999;
  }

  :deep(.el-date-editor) {
    width: 120px;
  }

  :deep(.el-input__wrapper) {
    width: 120px;
  }

  //:deep(.activeColor) {
  //  color: #1c49ff;
  //}

  .designDraft {
    cursor: pointer;
    padding: 5px;

    .el-image__error {
      background-color: #12bfda;
      color: #fff;
    }

    .el-image {
      width: 68px;
    }
  }

  :deep(.operate) {
    .cell {
      display: flex;
      align-items: center;
      justify-content: space-evenly; 

      .icon-xiugai,
      .icon-xiangqing {
        color: #1947ff;
      }

      .icon-shanchu1 {
        color: #fb3535;
      }
    }
  }

  :deep(.el-table .el-table__header-wrapper th, .el-table .el-table__fixed-header-wrapper th) {
    font-size: 15px !important;
  }

  // 内容居中显示（针对预警栏）
  :deep(.cell) {
    display: flex;
    align-items: center;
    justify-content: center;
    // justify-content: space-evenly;  //此处先注释掉，因为这样设置排序标志和同级标题间距大
    min-height: 40px;
    width: 100%;
  }

  // 预警
  // 警告色
  :deep(.stockroomNumber) {
    width: 74px;
    height: 26px;
    border-radius: 2px 2px 2px 2px;
    background: #ffece8;
    color: #f53f3f;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  // 正常
  :deep(.normal) {
    width: 74px;
    height: 26px;
    border-radius: 2px 2px 2px 2px;
    background: #e8ffea;
    color: #00b42a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  // 审核状态
  :deep(.审核通过) {
    background: #e8ffea;
    color: #00b42a;
    @include btn;
  }

  :deep(.未审核) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.待审核),
  :deep(.未收款) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.待上传合同) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.已核算) {
    background: #e8ffea;
    color: #00b42a;
    @include btn;
  }

  :deep(.未下单) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.已下单),
  :deep(.已收款) {
    background: #e8ffea;
    color: #00b42a;
    @include btn;
  }

  // 安装队管理
  :deep(.已完成) {
    background: #e8ffea;
    color: #00b42a;
    @include btn;
  }

  :deep(.待处理) {
    background: #ffece8;
    color: #f53f3f;
    @include btn;
  }

  :deep(.待分配) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.施工中) {
    background: #e8f3ff;
    color: #165dff;
    @include btn;
  }

  :deep(.待回访) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.未接单) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.待接单) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.进行中),
  :deep(.跟进中) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.待验收) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  :deep(.上传公费) {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  // 客户等级
  .C,
  .C级 {
    background: #e8f3ff;
    color: #165dff;
    @include btn;
  }

  .B,
  .B级 {
    background: #fcf1ff;
    color: #d325ff;
    @include btn;
  }

  .A,
  .A级 {
    background: #fff7e8;
    color: #ff7d00;
    @include btn;
  }

  .D,
  .D级 {
    background-color: #f7f8fa;
    color: #86909c;
    @include btn;
  }

  :deep(.合同到期) {
    background: #ffece8;
    color: #f53f3f;
    @include btn;
  }

  @mixin noticeType {
    width: 60px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border: 1px solid #dadada;
  }

  // 通告
  :deep(.活动) {
    @include noticeType;
    background: #fff7e8;
    color: #ff7d00;
  }

  :deep(.消息) {
    @include noticeType;
    background: #e8ffea;
    color: #00b42a;
  }

  :deep(.通知) {
    @include noticeType;
    background: #e8f3ff;
    color: #165dff;
  }

  :deep(.预警) {
    @include noticeType;
    background: #ffece8;
    color: #f53f3f;
  }

  // 设置中心
  :deep(.通过) {
    color: #069f0b;
    background-color: #a8fbab;
    @include btn;
  }

  :deep(.驳回) {
    background: #ffece8;
    color: #f53f3f;
    @include btn;
  }
  //活动列表

  .operate,
  .devise {
    padding: 5px;
    cursor: pointer;

    span {
      padding: 0 5px;
      //font-size: 12px;
      color: #1947ff;
    }
  }

  span {
    cursor: pointer;
  }

  .companyOperations-header {
    margin: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .sift {
      display: flex;
      align-items: center;
      color: #7386d1;
      margin-right: 20px;
      cursor: pointer;

      .iconfont {
        font-size: 20px;
      }
    }

    .siftData {
      cursor: pointer;
      line-height: 25px;

      p {
        text-align: center;
      }

      .activeTime {
        color: #1947ff;
      }
    }
  }

  .pageNum {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .icon-close {
    border-radius: 50%;
    border: 1px solid #000;
    font-size: 22px;
  }

  .setcompanyOperations {
    label {
      display: flex;
      align-items: center;
      justify-content: space-evenly;
      line-height: 80px;
    }

    .btn-sub {
      width: 100%;
      text-align: center;
    }
  }
}
//表格中图片展示
.tabelimg{
   width: 50px;
   height: 50px;
   vertical-align: middle;
}
</style>
